﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AMS.Inventory.PCClient
{
    public partial class ProcessForm : Form
    {
        private BackgroundWorker backgroundWorker1;
        private static int Maxinum = 0;
        public ProcessForm(BackgroundWorker backgroundWorker1,int MaxNum)
        {

            InitializeComponent();
           
            this.backgroundWorker1 = backgroundWorker1;
            Maxinum = MaxNum;
            progressBar1.Maximum = Maxinum;
           
            this.backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);

            this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);

        }

        void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {

            Close();

        }



        void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            progressBar1.Maximum = Maxinum;
            progressBar1.Value = e.ProgressPercentage;

        }


 

        private void cancelButton1_Click_1(object sender, EventArgs e)
        {
            backgroundWorker1.CancelAsync();

            cancelButton1.Enabled = false;

            Close();
        }
 
    }
}
